/**
 * Created by Administrator on 2017/5/22.
 */
module.exports = function (sequelize, DataTypes) {
    var _model = sequelize.define("task", {
        taskid: {type: DataTypes.UUID, primaryKey: true, comment: '任务ID'}
        , userid: {
            type:DataTypes.STRING(100), comment: '用户ID', references: {
                model: sequelize.models.user
                , key:'userid'
            }
        }
        , success: {type: DataTypes.STRING(15), comment: '完成记录'}
        , progress: {type:DataTypes.INTEGER, comment: '任务进度'}
        , title: {type: DataTypes.STRING(50), allowNull: false, comment: '任务名称'}
        , sort: {type: DataTypes.INTEGER, allowNull: false, comment: '优先级'}
        , content:{type:DataTypes.TEXT("long"),defaultValue:"", comment: '任务内容'}
        , ext: {type: DataTypes.TEXT("long"), comment: '属于那个project的'}
    }, {
        indexes: [ {
            name: 'sort'
            , fields: ['sort']
        }]
        , classMethods: {
            associate: function (models) {
                _model.belongsTo(models.user, {foreignKey: 'userid'});
            }
        }
    });
    return _model;
};